// reducers/user.jsx
import { createSlice } from "@reduxjs/toolkit";

const initialState = {
  token: null,
  isLogin: false,
};

const user = createSlice({
  name: "user",
  initialState,
  reducers: {
    setToken: (state, action) => {
      // 将传入的值设置为 token 的新值
      state.token = action.payload.token;
      state.isLogin = action.payload.isLogin;
    },
    resetToken: (state) => {
      return initialState;
    },
  },
});

export const { setToken, resetToken } = user.actions;
export default user.reducer;
